import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';

class MinePage extends StatefulWidget {
  const MinePage({super.key});

  @override
  State<MinePage> createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {

/// 退出 APP 方式一
  void _doQuit() async {
    await SystemChannels.platform.invokeMethod('SystemNavigator.pop');
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.only(left: 10,top: 10,right: 10,bottom: 20),
          child: Row(
            children: [
              ClipOval(
                child: Image.asset(
                  'assets/images/head.jpg',
                  width: 80,
                  height: 80,
                ),
              ),
              SizedBox(
                width: 10,
              ),
              Text('用户名')
            ],
          ),
        ),
        Divider(
          height: 1,
          color: Colors.black,
        ),
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            children: [
              Icon(Icons.history),
              SizedBox(
                width: 10,
              ),
              Text('浏览历史'),
              Spacer(),
              Icon(Icons.keyboard_arrow_right),
            ],
          ),
        ),
        Divider(
          height: 1,
          color: Colors.black,
        ),
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            children: [
              Icon(Icons.wallet_membership),
              SizedBox(
                width: 10,
              ),
              Text('会员中心'),
              Spacer(),
              Icon(Icons.keyboard_arrow_right),
            ],
          ),
        ),
        Divider(
          height: 1,
          color: Colors.black,
        ),
        InkWell(
          onTap: () {
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
              content: Text('点击了我的客服'),
            ));
          },
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Row(
              children: [
                Icon(Icons.online_prediction),
                SizedBox(
                  width: 10,
                ),
                Text('我的客服'),
                Spacer(),
                Icon(Icons.keyboard_arrow_right),
              ],
            ),
          ),
        ),
        Divider(
          height: 1,
          color: Colors.black,
        ),
        Spacer(),
        MaterialButton(
            color: Colors.green.shade900,
            textColor: Colors.white,
            onPressed: () {
              showDialog(
                  context: context,
                  builder: (BuildContext context) {
                    return AlertDialog(
                      title: const Text("提示"),
                      content: const Text("确认退出APP吗？"),
                      actions: [
                        MaterialButton(
                          child: const Text("狠心退出"),
                          onPressed: () {
                            Navigator.of(context).pop();
                            _doQuit();
                          },
                        ),
                      ],
                    );
                  });
            },
            child: Text('退出登录'))
      ],
    );
  }
}
